package com.qf.smsplatform.strategy.config;

import com.qf.smsplatform.common.constants.RabbitMQConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Author: LeeRui
 * 2021/1/28 上午 1:35
 **/
@Configuration
public class Rabbitconfig {

    /**
     *
     *下发日志到MQ队列
     * @return
     */

    //创建交换机
    @Bean
    public Exchange sendMQExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_SMS_SEND_LOG+"_exchange").build();
    }

    //创建队列
    @Bean
    public Queue sendMQQueue(){
        return QueueBuilder.durable(RabbitMQConstants.TOPIC_SMS_SEND_LOG).build();
    }

    //交换机与队列绑定
    @Bean
    public Binding sendMQBiding(Queue sendMQQueue,Exchange sendMQExchange){
        return BindingBuilder.bind(sendMQQueue).to(sendMQExchange).with("#").noargs();
    }

    /**
     *
     *推送报告
     * @return
     */

    //创建交换机
    @Bean
    public Exchange pushSmsReportExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_PUSH_SMS_REPORT + "_exchange").build();
    }
    //创建队列
    @Bean
    public Queue pushSmsReportQueue(){
        return QueueBuilder.durable(RabbitMQConstants.TOPIC_PUSH_SMS_REPORT).build();
    }
    //交换机与队列绑定
    @Bean
    public Binding pushSmsReportBinding(Queue pushSmsReportQueue,Exchange pushSmsReportExchange){
        return BindingBuilder.bind(pushSmsReportQueue).to(pushSmsReportExchange).with("#").noargs();
    }
}
